//package cmpe451.group7.ourcity.persistance;
//
//import org.hibernate.SessionFactory;
//import org.hibernate.cfg.Configuration;
//
//import cmpe451.group7.ourcity.util.GlobalVariables;
//import cmpe451.group7.ourcity.util.Logger;
//
///**
// * Utility class for creating Hibernate sessions
// */
//public class HibernateUtil {
//
//	private static boolean SWITCH_MYSQL_HSQLDB = false;
//	private static final SessionFactory sessionFactory = buildSessionFactory();
//	static {
//		if (SWITCH_MYSQL_HSQLDB) {
//			new DatabaseInitializer().initialize();
//		}
//	}
//
//	/**
//	 * Creates a session factory for the whole application. This is called only
//	 * once.
//	 * 
//	 * @return
//	 */
//	@SuppressWarnings("deprecation")
//	private static SessionFactory buildSessionFactory() {
//		try {
//			String runningTests = System.getProperty("RUNNING_TESTS");
//			System.out.println("RUNNING_TESTS: " + runningTests);
//			boolean runningTestsCheck = runningTests != null
//					&& runningTests.equalsIgnoreCase("true");
//
//			boolean debugging = Boolean.parseBoolean(GlobalVariables.properties
//					.getProperty("TESTING"));
//
//			String hibernateConf = null;
//			if (runningTestsCheck || debugging || SWITCH_MYSQL_HSQLDB) {
//				hibernateConf = "hibernate-hsqldb.cfg.xml";
//				System.out.println("HSQLDB");
//			} else {
//				hibernateConf = "hibernate.cfg.xml";
//				System.out.println("MYSQL");
//			}
//
//			// Create the SessionFactory from
//			return new Configuration().configure(hibernateConf)
//					.buildSessionFactory();
//		} catch (Throwable ex) {
//			// Make sure you log the exception, as it might be swallowed
//
//			Logger.log("Initial SessionFactory creation failed." + ex);
//			throw new ExceptionInInitializerError(ex);
//		}
//	}
//
//	/**
//	 * Get the session factory object
//	 * 
//	 * @return
//	 */
//	public static SessionFactory getSessionFactory() {
//		return sessionFactory;
//	}
//
//	public static void shutdown() {
//		// Close caches and connection pools
//		getSessionFactory().close();
//	}
//
//}